#include "DoxMemberDef.h"
#include "DoxyBool.h"

DoxMemberDef::DoxMemberDef():
    m_static(false),
    m_mutable(false)
{
}

bool DoxMemberDef::loadConfig(const QDomElement &element)
{
    bool returnBool = false;

    if(!element.isNull())
    {
        //load in the attribute data from the configuration file
        m_kind = Enumerators::DoxMemeberKind::DoxMemeberKindFromString(element.attribute("kind"));
        m_protection = Enumerators::ProtectionType::protectionFromString(element.attribute("prot"));
        m_static = DoxyBool::boolFromString(element.attribute("static"));
        m_mutable = DoxyBool::boolFromString(element.attribute("mutable"));
        m_ref.refId = element.attribute("id");
        m_const = DoxyBool::boolFromString(element.attribute("const"));
        m_explicit = DoxyBool::boolFromString(element.attribute("explicit"));
        m_inline = DoxyBool::boolFromString(element.attribute("inline"));
        m_virtual = Enumerators::VirtualType::virtualFromString(element.attribute("virt"));
        m_volitile = DoxyBool::boolFromString(element.attribute("volatile"));


        QDomNodeList list = element.childNodes();

        for(int i =0; i < list.size(); i++)
        {
            if(!list.at(i).isNull())
            {
                if(list.at(i).isElement())
                {
                    QDomElement subElement  = list.at(i).toElement();
                    loadSubElements(subElement);
                }
            }
        }
    }
    qDebug() << m_ref.name;

}

Enumerators::SectionDefKind::DoxSectionKind_E DoxMemberDef::getType() const
{
}

void DoxMemberDef::loadSubElements(const QDomElement &element)
{
    if(element.tagName() == "name")
    {
       m_ref.name = element.text();
    }
    else if(element.tagName() == "location")
    {
        QString text = element.attribute("file");
        m_fileLocation.setHeaderFileName(text);

        text = element.attribute("line");
        m_fileLocation.setLineNoBegin(text.toInt());

        text = element.attribute("bodyfile");
        m_fileLocation.setBaseFileName(text);

        text = element.attribute("bodystart");
        m_fileLocation.setLineNoBegin(text.toInt());


        text = element.attribute("bodyend");
        m_fileLocation.setLineNoEnd(text.toInt());
    }
    else if(element.tagName() == "templateparamlist")
    {

    }
    else if(element.tagName() == "type")
    {

    }
    else if (element.tagName() == "definition")
    {

    }
    else if (element.tagName() == "argsstring")
    {

    }
    else if (element.tagName() == "reimplements")
    {

    }
    else if (element.tagName() == "reimplementedby")
    {

    }

}
